<?php


#--------------------------------------------------
# ALL INCLUDES + STANDARD-VALUES
#--------------------------------------------------
include_once ("include/config.inc");
include_once ("include/template.inc");
include_once ("include/class.db.php5");
include_once ("include/class.tools.php5");
$svo = new db("svoptik");
$tools = new tool();

include_once ("include/global_fix_extern.inc");
include_once ("stats_inc.php5");

#--------------------------------------------------
# CREATE TEMPLATE
#--------------------------------------------------
$t = new Template("templates", "keep");
$t->set_file(array (
	"page" => "svoptik.tpl",
	"ticker" => "ticker.tpl",
	"navi" => "navi.tpl",
	"team" => "team_stats.tpl"
));
#--------------------------------------------------
$t->set_var(array (
	"FORWARD" => ""
));
#--------------------------------------------------
# CREATE ALL-TIME SAME THINGS
#--------------------------------------------------
include_once ("include/sameThings.php5");

#--------------------------------------------------

#--------------------------------------------------
# CREATE NAVIGATION RIGHT
#--------------------------------------------------
if (!isset($team_id)){
	$team_id = 1;
}
// Team laden
$actTeam = $teamDao->findById($team_id);
$links = "";
$m = 1;
$url[0] = array (
	"URL" => "",
	"URL-TEXT" => $actTeam->name,
	"ONCLICK" => "",
	"TARGET" => "_self"
);
$url[$m++] = array (
	"URL" => "team.php5?team_id=" . $team_id . "&cat=News",
	"URL-TEXT" => "-&nbsp;News",
	"ONCLICK" => "",
	"TARGET" => "_self"
);
$url[$m++] = array (
	"URL" => "team.php5?team_id=" . $team_id . "&cat=Team",
	"URL-TEXT" => "-&nbsp;Team",
	"ONCLICK" => "",
	"TARGET" => "_self"
);
$url[$m++] = array (
	"URL" => "team_tab.php5?team_id=" . $team_id,
	"URL-TEXT" => "-&nbsp;Tabelle",
	"ONCLICK" => "",
	"TARGET" => "_self"
);
$url[$m++] = array (
	"URL" => "team_schedule.php5?team_id=" . $team_id . "&complete=0",
	"URL-TEXT" => "-&nbsp;Spielplan",
	"ONCLICK" => "",
	"TARGET" => "_self"
);
$url[$m++] = array (
	"URL" => "",
	"URL-TEXT" => "-&nbsp;Statistiken",
	"ONCLICK" => "",
	"TARGET" => "_self"
);
/* $players = $svo->doSQL("select distinct gp.*, gt.*, p.*, t.* from ".$table['G_Player']." as gp, ".$table['Player']." as p, ".$table['G_Team']." as gt, ".$table['Team']." as t where gp.stats_player_global_id=p.stats_player_id_global && p.stats_player_team_id=t.stats_team_id && gt.stats_team_global_id=t.stats_team_global_id && t.stats_team_id=".$team_id." order by gp.stats_player_global_name asc, gp.stats_player_global_vname asc;");
  while ($row = $svo->getRecordset($players)) {
    $url[] = array("URL"      => "player_stats.php5?team_id=".$team_id."&player_id=".$row['stats_player_id_global'],
                   "URL-TEXT" => "&nbsp;&nbsp;&nbsp;&raquo;&nbsp;".$tools->html_replace($row['stats_player_global_name'].", ".substr($row['stats_player_global_vname'],0,1)).".",
                   "ONCLICK"  => "",
                   "TARGET"   => "_self");
  }
*/
$url[$m++] = array (
	"URL" => "",
	"URL-TEXT" => "SPACER",
	"ONCLICK" => "",
	"TARGET" => "_self"
);

for ($i = 0; $i < count($url); $i++) {
	if ($url[$i]['URL-TEXT'] != "SPACER") {
		if (!empty ($url[$i]['URL']))
			$slink = "<a href=\"" . $url[$i]['URL'] . "\" class=\"sitenav\" target=\"" . $url[$i]['TARGET'] . "\" onClick=\"" . $url[$i]['ONCLICK'] . "\">" . $tools->html_replace($url[$i]['URL-TEXT']) . "</a>";
		else
			$slink = "<b>" . $tools->html_replace($url[$i]['URL-TEXT']) . "</b>";
	} else
		$slink = "&nbsp;";
	$links .= "
					<tr height=\"15\">
						<td valign=\"top\"><img src=\"standard/spacer.gif\" width=\"20\" height=\"15\" border=\"0\" alt=\"\"></td>
						<td valign=\"top\" class=\"sitenav\">" . $slink . "</td>
						<td valign=\"top\"><img src=\"standard/spacer.gif\" width=\"20\" height=\"15\" border=\"0\" alt=\"\"></td>
					</tr>
		       	";

}
$liga = strtolower($team_data['stats_leagues_global_shortname']);
$t->set_var(array (
	"LINKS" => $links,
	"BANNER" => $banner,
	"LIGA" => $actTeam->liga,
	"SAISON" => $actTeam->saison
));
$right_nav = $t->parse("", "navi", true);
#--------------------------------------------------

#--------------------------------------------------
# CREATE CONTENT "STATS"
#--------------------------------------------------

$content = $t->parse("", "team", true);
#--------------------------------------------------

#--------------------------------------------------
# PARSE & OUTPUT
#--------------------------------------------------
$t->set_var(array (
	"sitenav" => "TEAMS -> " . $tools->html_replace(strtoupper("Red Eagles Rathenow - " . $actTeam->name . " " . $actTeam->suffix
)) . " (SAISON " . $actTeam->saison . "/".($actTeam->saison + 1).") -> STATISTIKEN", //.$team_data['stats_season_name'].")",
"ticker" => $ticker, "content" => $content . "<br>", "navi" => $right_nav,
	"SYNCHRONIZE" => " "));

$t->parse("ALL", "page", true);
$t->p("ALL");
?>
